package com.aiyige.richtexteditor.model;

import android.os.Parcel;
import android.os.Parcelable;

public class RTELocalMedia implements Parcelable {
    public static final int TYPE_VIDEO = 1;
    public static final int TYPE_PHOTO = 2;
    int type;
    String photoUrl;
    String videoUrl;
    String videoCoverUrl;
    String videoOriginalCoverUrl;
    String mediaId;
    long mediaDuration;

    public RTELocalMedia() {
    }

    private RTELocalMedia(Builder builder) {
        setType(builder.type);
        setPhotoUrl(builder.photoUrl);
        setVideoUrl(builder.videoUrl);
        setVideoCoverUrl(builder.videoCoverUrl);
        setVideoOriginalCoverUrl(builder.videoOriginalCoverUrl);
        setMediaId(builder.mediaId);
        setMediaDuration(builder.mediaDuration);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getPhotoUrl() {
        return photoUrl;
    }

    public void setPhotoUrl(String photoUrl) {
        this.photoUrl = photoUrl;
    }

    public String getVideoUrl() {
        return videoUrl;
    }

    public void setVideoUrl(String videoUrl) {
        this.videoUrl = videoUrl;
    }

    public String getVideoCoverUrl() {
        return videoCoverUrl;
    }

    public void setVideoCoverUrl(String videoCoverUrl) {
        this.videoCoverUrl = videoCoverUrl;
    }

    public String getVideoOriginalCoverUrl() {
        return videoOriginalCoverUrl;
    }

    public void setVideoOriginalCoverUrl(String videoOriginalCoverUrl) {
        this.videoOriginalCoverUrl = videoOriginalCoverUrl;
    }

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    public long getMediaDuration() {
        return mediaDuration;
    }

    public void setMediaDuration(long mediaDuration) {
        this.mediaDuration = mediaDuration;
    }

    public static final class Builder {
        private int type;
        private String photoUrl;
        private String videoUrl;
        private String videoCoverUrl;
        private String videoOriginalCoverUrl;
        private String mediaId;
        private long mediaDuration;

        private Builder() {
            mediaId = "";
        }

        public Builder type(int val) {
            type = val;
            return this;
        }

        public Builder photoUrl(String val) {
            photoUrl = val;
            return this;
        }

        public Builder videoUrl(String val) {
            videoUrl = val;
            return this;
        }

        public Builder videoCoverUrl(String val) {
            videoCoverUrl = val;
            return this;
        }

        public Builder videoOriginalCoverUrl(String val) {
            videoOriginalCoverUrl = val;
            return this;
        }

        public Builder mediaId(String val) {
            mediaId = val;
            return this;
        }

        public Builder mediaDuration(long val) {
            mediaDuration = val;
            return this;
        }

        public RTELocalMedia build() {
            return new RTELocalMedia(this);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.type);
        dest.writeString(this.photoUrl);
        dest.writeString(this.videoUrl);
        dest.writeString(this.videoCoverUrl);
        dest.writeString(this.videoOriginalCoverUrl);
        dest.writeString(this.mediaId);
        dest.writeLong(this.mediaDuration);
    }

    protected RTELocalMedia(Parcel in) {
        this.type = in.readInt();
        this.photoUrl = in.readString();
        this.videoUrl = in.readString();
        this.videoCoverUrl = in.readString();
        this.videoOriginalCoverUrl = in.readString();
        this.mediaId = in.readString();
        this.mediaDuration = in.readLong();
    }

    public static final Creator<RTELocalMedia> CREATOR = new Creator<RTELocalMedia>() {
        @Override
        public RTELocalMedia createFromParcel(Parcel source) {
            return new RTELocalMedia(source);
        }

        @Override
        public RTELocalMedia[] newArray(int size) {
            return new RTELocalMedia[size];
        }
    };
}